#include <asm.h>
.intel_syntax noprefix

/// <summary>
/// void clBGRA32ToRGBA32(void *buffer, unsigned int count)
/// </summary>
.globl clBGRA32ToRGBA32
clBGRA32ToRGBA32:
	push ebp
	mov ebp, esp
	mov ecx, [ebp+8]
	mov edx, [ebp+12]
	add	edx, 3
	sar	edx, 2
	run_loop:
	mov al, [ecx+0]
	mov ah, [ecx+2]
	mov [ecx+2], al
	mov [ecx+0], ah
	add ecx, 4
	dec edx
	jnz run_loop
	mov eax, edx
	mov esp, ebp
	pop ebp
	emms
	ret

/// <summary>
/// Globals
/// void BGRAFloatToRGBAFloat(void *buffer, unsigned int count)
/// </summary>
.globl _BGRAFloatToRGBAFloat
_BGRAFloatToRGBAFloat:
	push ebp
	mov ebp, esp
	mov ecx, [ebp+8]
	mov edx, [ebp+12]
	run_0:
	movups xmm0, [ecx]
	pshufd xmm0, xmm0, 0xC6
	movups [ecx], xmm0
	add ecx, 16
	dec edx
	jnz run_0
	mov eax, edx
	mov esp, ebp
	pop ebp
	emms
	ret
